


use "stata data/A1 data -8 to 8 HUGE", clear //know just want the 38/42 part

keep if event_day == 1

keep if year == 2014
gen dow = dow(date)
keep if inrange(dow,1,5)
drop if date == mdy(7,4,2014) //july 4th
drop if date == mdy(9,1,2014) //Labour day

merge m:1 sa using "stata data/sas_used_in_regressions" //from step 7
keep if _merge == 3
drop _merge


gen eligible = 0
replace eligible = 1 if bin >=0

gen temp_f_2 = temp_f^2

gen month = month(date)

reghdfe kwh    , absorb(sa)  residuals(kwh_residual_sa_notemp) 



compress *

save "temp/A1 PDP all hours HUGE regressed", replace


use "temp/A1 PDP all hours HUGE regressed", clear

fcollapse (mean) kwh*, by(hour eligible) 

save "temp/temp33", replace

use "temp/temp33", clear



label variable kwh_residual_sa_notemp "Electricity consumption (residual kWh)"
label variable hour "Hour"

replace hour = 24 if hour == 0
sort hour eligible

twoway 	(line kwh_residual_sa_notemp hour if eligible == 1,  color(black) fi(48) lpattern(dash) lwidth(medthick)) ///
		(line kwh_residual_sa_notemp hour if eligible == 0 , lcolor(orange)lwidth(medthick) fi(48)), ///
		 legend(label(1 Eligible) label(2 Ineligible)) graphregion(color(white)) bgcolor(white) ylabel(,grid glcolor(gs15) angle(0)) ///
		   xlab(2 "2am" 6 "6am" 10 "10am"  14 "2pm" 18 "6pm" 22 "10pm")  xline(14 18, lwidth(mediumthick) lcolor(gs10)) 

		
graph export "latex//Pre_period_consumption_bin_8_color.pdf", replace 







